home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / amigadoslibrary / fwrite.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  1KB  |  51 lines

  1. /* FWrite.c   V1.2   93-03-03                  */
  2. /* ROM library: "dos.library/FWrite", (V36+)   */
  3. /* Copyright 1993, Anders Bjerin, Amiga C Club */
  4.  
  5. #include <dos/dos.h>
  6.  
  7. #include <clib/dos_protos.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. #define BLOCK_SIZE  10
  12. #define NO_BLOCKS    3
  13.  
  14. UBYTE *version = "$VER: FWrite 1.2";
  15.  
  16. int main( int argc, char *argv[] );
  17. int main( int argc, char *argv[] )
  18. {
  19.   BPTR my_file;
  20.   LONG blocks_write;
  21.   UBYTE my_buffer[ NO_BLOCKS ][ BLOCK_SIZE ]=
  22.   {
  23.     { 34, 12, 54, 54, 65, 75, 56, 86, 86, 86 },
  24.     { 23, 26, 74, 85, 34, 16, 98, 65, 47, 43 },
  25.     { 21, 34, 74, 67, 90, 53, 23, 56, 84, 65 }
  26.   };
  27.  
  28.  
  29.   /* Open a new file: */
  30.   my_file = Open( "RAM:Important.dat", MODE_NEWFILE );
  31.   if( !my_file )
  32.     exit( 20 );
  33.  
  34.   /* Clear the global error code: */
  35.   SetIoErr( 0 );
  36.  
  37.   /* Write the data: */
  38.   blocks_write = FWrite( my_file, my_buffer, BLOCK_SIZE, NO_BLOCKS );
  39.  
  40.   /* OK? */
  41.   if( blocks_write != NO_BLOCKS )
  42.     printf( "Not all data was saved!" );
  43.   else
  44.     printf( "The data was successfully saved!\n" );
  45.  
  46.   Close( my_file );
  47.  
  48.   exit( 0 );
  49. }
  50.  
  51.